/*
 * Powered By xTOOLs
 * Dev by tao.li8@pactera.com
 * Copyright ©2009-2018 pactera.com All rights reserved.
 *
 * Generated at 2020-7-1 10:53:27
 */

package com.pactera.jep.service.yapin.coll.service.impl;

import com.pactera.jep.orm.mybatis.entity.Example;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pactera.jep.orm.mybatis.mapper.Mapper;
import com.pactera.jep.orm.mybatis.service.MyBatisCRUDService;

import com.pactera.jep.service.yapin.coll.mapper.CollateralCatalogMapper;
import com.pactera.jep.service.yapin.coll.service.CollateralCatalogService;
import com.pactera.jep.service.yapin.coll.model.CollateralCatalog;

import java.util.List;

/**
 * 服务层实现
 * @author YourName
 * @date 2020-7-1 10:53:27
 */

@Service
@Transactional
public class CollateralCatalogServiceImpl extends MyBatisCRUDService<CollateralCatalog, String> implements CollateralCatalogService {

    Logger logger =  LoggerFactory.getLogger(getClass());

    @Autowired
    private CollateralCatalogMapper	collateralCatalogMapper;

    @Override
    public Mapper<CollateralCatalog, String> getMapper() {
         return collateralCatalogMapper;
    }

    @Override
    public CollateralCatalog getCollateralCatalog(String cltTpCd) {
        CollateralCatalog collateralCatalog = null;
        Example example = new Example(CollateralCatalog.class);
        example.createCriteria().andEqualTo("catalogCd",cltTpCd);
        List<CollateralCatalog> collateralCatalogs = collateralCatalogMapper.selectByExample(example);
        if (collateralCatalogs.isEmpty()){
            collateralCatalog = new CollateralCatalog();
        }else {
            collateralCatalog = collateralCatalogs.get(0);
        }
        return collateralCatalog;
    }
}
